package tech.aistar.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 本类用来演示:
 *
 * @author: success
 * @date: 2021/4/16 2:02 下午
 */
//@WebFilter(urlPatterns = "/*")
public class FillterDemo implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        //校验 - 该过滤器是放行还是不放行..
        System.out.println("filter...");

        //此行如果出现,代表filter是放行的.
        //if(判断是否登录) {
        filterChain.doFilter(servletRequest, servletResponse);
//        }else{
//            HttpServletResponse resp = (HttpServletResponse) servletResponse;
//            resp.sendRedirect("/aistar/user/loginView");
//        }
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("init...");
    }

    @Override
    public void destroy() {
        System.out.println("destroy...");
    }
}
